/**
 * author:Administrator
 * date:2016/3/25
 * desc:TODO
 */
'use strict';

class VendorWareDetail {
  constructor(data) {
    this.parse(data);
    Object.freeze(this);
  }

  parse(data) {
    if (!data || !Array.isArray(data) || data.length == 0) return;

    let item0 = data[0];
    this.id = item0.id;
    this.vendorId = item0.vendorId;
    this.name = item0.name;
    this.locationId = item0.locationId;
    this.status = item0.status;
    this.keeperId = item0.keeperId;
    this.imgUrls = item0.imgUrls;
    this.addr = item0.addr;
    this.openTime = item0.openTime;
    this.closeTime = item0.closeTime;
    this.tel = item0.tel;
    this.desc = item0.desc;
    this.createdAt = item0.createdAt;
    this.updatedAt = item0.updatedAt;

    this.wareList = data.map(item => {
      return {
        id: item.wareId,
        name: item.wareName,
        cateName: item.cateName
      }
    });
  }
}

module.exports = VendorWareDetail;